package com.practice.java8.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MapMain {
	
	public static void main(String[] args) {
		map();
		flatMap();
	}
	
	public static void map() {
		List<Integer> nums = Arrays.asList(1, 2, 3, 4);
		List<Integer> squareNums = nums.stream().
		map(n -> n * n).
		collect(Collectors.toList());
	}
	
	public static void flatMap() {
		Stream<List<Integer>> inputStream = Stream.of(
				 Arrays.asList(1),
				 Arrays.asList(2, 3),
				 Arrays.asList(4, 5, 6)
				 );
		Stream<Integer> outputStream = inputStream.
		flatMap((childList) -> childList.stream());
	}
		
}
